<div class="modal-dialog">
    <link rel="stylesheet" href="{URL_MODULE}web/resource/css/utility.css">
    <div class="modal-content">
        <!--顶部标题-->
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h4 class="modal-title">选择链接</h4>
        </div>
        <!--中间内容-->
        <div class="modal-body">
        	<ul class="nav nav-tabs" id="selectUrlTab">
				<li class="active" data-id="system"><a href="javascript:;">系统连接</a></li>
                <li class="" data-id="cate"><a href="javascript:;">分类连接</a></li>
                <li class=""  data-id="shop"><a href="javascript:;">店铺链接</a></li>
                {if p('rush') || p('wlfightgroup') || p('groupon') || p('wlcoupon') || p('bargain')}
                    <li class="" data-id="select_goods"><a href="javascript:;">商品选择</a></li>
                {/if}
                {if $pageInfo}
                    <li class=""  data-id="page"><a href="javascript:;">页面链接</a></li>
                {/if}
                {if p('rush')}
                    <li class=""  data-id="rushspecial"><a href="javascript:;">抢购专题</a></li>
                {/if}
                <li class="" data-id="add_link"><a href="javascript:;">自定义链接</a></li>
                <li class="" data-id="add_appid"><a href="javascript:;">小程序跳转</a></li>
                <li class="" data-id="add_phone"><a href="javascript:;">拨打电话</a></li>
			</ul>
			<div class="tab-content" id="selectUrlContent">
                <!--系统选择-->
				<div class="tab-pane active" id="url_system">
					{loop $system $item}
						<div class="page-head"><h5 class="margin-0"><i class="fa fa-folder-open-o"></i> {$item['name']}</h5></div>
						{loop $item['list'] $child}
							<nav data-href="{php echo $child['url']}" class="btn btn-default btn-sm" title="{$child['name']}" data-page_path="{$child['page_path']}" data-type="{$child['url_type']}" >{$child['name']}</nav>
						{/loop}
					{/loop}
				</div>
                <!--分类连接-->
                <div class="tab-pane" id="url_cate">
                    {loop $cate $item}
                    <div class="page-head"><h5 class="margin-0"><i class="fa fa-folder-open-o"></i> {$item['name']}</h5></div>
                        {loop $item['list'] $child}
                            <nav data-href="{php echo $child['url']}" class="btn btn-default btn-sm" title="{$child['name']}" data-page_path="{$child['page_path']}" data-type="{$child['url_type']}" >{$child['name']}</nav>
                        {/loop}
                    {/loop}
                </div>
                <!--店铺链接-->
                <div class="tab-pane " id="url_shop">
                    <div class="page-search">
                        <div class="col-sm-9">
                            <input type="text" name="name" class="form-control col-sm-9"/>
                        </div>
                        <span class="btn btn-primary min-width confirmSearch">搜索</span>
                    </div>
                    <div class="app-table-list">
                        <div class="panel panel-default">
                            <table class="table table-hover table-responsive table-bordered">
                                <thead class="navbar-inner">
                                    <tr>
                                        <th width="20%" class="text-center">店铺图标</th>
                                        <th width="20%" class="text-center">店铺名称</th>
                                        <th width="20%" class="text-center">营业时间</th>
                                        <th width="20%" class="text-center">操作</th>
                                    </tr>
                                </thead>
                                <tbody id="shopList">
                                    {loop $shopList['list'] $key $val}
                                        <tr class="text-center">
                                            <td><img src="{$val['logo']}" class="url_images"/></td>
                                            <td  class="text-left">{$val['storename']}</td>
                                            <td>{$val['storehours']}</td>
                                            <td>
                                                <nav data-href="{php echo $val['url']}" class="btn btn-default btn-sm" title="{$child['storename']}" data-page_path="{$child['page_path']}" data-type="{$val['url_type']}" >选择</nav>
                                            </td>
                                        </tr>
                                    {/loop}
                                </tbody>
                            </table>
                            <div class="pagerContent" pageNum="{$shop_pageNum}" total="{$shop_total}" id="shopPager" htmlID="shopList"></div>
                        </div>
                    </div>
                </div>
                <!--商品选择-->
                <div class="tab-pane " id="url_select_goods">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <div class="btn-group">
                                {if ('rush')}<a href="javascript:;" class="btn btn-default goods_option" data-type="rush">抢购</a>{/if}
                                {if ('wlfightgroup')}<a href="javascript:;" class="btn btn-default goods_option" data-type="fightgroup">拼团</a>{/if}
                                {if ('groupon')}<a href="javascript:;" class="btn btn-default goods_option" data-type="groupon">团购</a>{/if}
                                {if ('wlcoupon')}<a href="javascript:;" class="btn btn-default goods_option" data-type="coupon">优惠券</a>{/if}
                                {if ('bargain')}<a href="javascript:;" class="btn btn-default goods_option" data-type="bargain">砍价</a>{/if}
                            </div>
                        </div>
                    </div>
                    <div class="page-search">
                        <div class="col-sm-9">
                            <input type="text" name="name" class="form-control col-sm-9"/>
                        </div>
                        <span class="btn btn-primary min-width confirmSearch">搜索</span>
                    </div>
                    <div class="app-table-list">
                        <!--抢购商品-->
                        <div id="rush" class="goods_list_content panel hide panel-default">
                            <table class="table table-hover table-responsive table-bordered">
                                <thead class="navbar-inner">
                                <tr>
                                    <th width="20%" class="text-center">商品图片</th>
                                    <th width="20%" class="text-center">商品名称</th>
                                    <th width="20%" class="text-center">操作</th>
                                </tr>
                                </thead>
                                <tbody id="rushList">
                                {loop $rush $key $val}
                                <tr class="text-center">
                                    <td><img src="{$val['logo']}" class="url_images"/></td>
                                    <td  class="text-left">{$val['name']}</td>
                                    <td>
                                        <nav data-href="{php echo $val['url']}" class="btn btn-default btn-sm" title="{$child['name']}" data-page_path="{$child['page_path']}" data-type="{$val['url_type']}" >选择</nav>
                                    </td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                            <div class="pagerContent" pageNum="{$rush_pageNum}" total="{$rush_total}" id="rushPager" type="1" htmlID="rushList"></div>
                        </div>
                        <!--拼团商品-->
                        <div id="fightgroup" class="goods_list_content panel hide panel-default">
                            <table class="table table-hover table-responsive table-bordered">
                                <thead class="navbar-inner">
                                <tr>
                                    <th width="20%" class="text-center">商品图片</th>
                                    <th width="20%" class="text-center">商品名称</th>
                                    <th width="20%" class="text-center">操作</th>
                                </tr>
                                </thead>
                                <tbody id="fightgroupList">
                                {loop $fightgroup $key $val}
                                <tr class="text-center">
                                    <td><img src="{$val['logo']}" class="url_images"/></td>
                                    <td  class="text-left">{$val['name']}</td>
                                    <td>
                                        <nav data-href="{php echo $val['url']}" class="btn btn-default btn-sm" data-page_path="{$child['page_path']}" title="{$child['name']}"  data-type="{$val['url_type']}" >选择</nav>
                                    </td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                            <div class="pagerContent" pageNum="{$fightgroup_pageNum}" total="{$fightgroup_total}" id="fightgroupPager" type="3" htmlID="fightgroupList"></div>
                        </div>
                        <!--团购商品-->
                        <div id="groupon" class="goods_list_content panel hide panel-default">
                            <table class="table table-hover table-responsive table-bordered">
                                <thead class="navbar-inner">
                                <tr>
                                    <th width="20%" class="text-center">商品图片</th>
                                    <th width="20%" class="text-center">商品名称</th>
                                    <th width="20%" class="text-center">操作</th>
                                </tr>
                                </thead>
                                <tbody id="grouponList">
                                {loop $groupon $key $val}
                                <tr class="text-center">
                                    <td><img src="{$val['logo']}" class="url_images"/></td>
                                    <td  class="text-left">{$val['name']}</td>
                                    <td>
                                        <nav data-href="{php echo $val['url']}" data-page_path="{$child['page_path']}" class="btn btn-default btn-sm" title="{$child['name']}"  data-type="{$val['url_type']}" >选择</nav>
                                    </td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                            <div class="pagerContent" pageNum="{$groupon_pageNum}" total="{$groupon_total}" id="grouponPager" type="2" htmlID="grouponList"></div>
                        </div>
                        <!--优惠券-->
                        <div id="coupon" class="goods_list_content panel hide panel-default">
                            <table class="table table-hover table-responsive table-bordered">
                                <thead class="navbar-inner">
                                <tr>
                                    <th width="20%" class="text-center">商品图片</th>
                                    <th width="20%" class="text-center">商品名称</th>
                                    <th width="20%" class="text-center">操作</th>
                                </tr>
                                </thead>
                                <tbody id="couponList">
                                {loop $coupon $key $val}
                                <tr class="text-center">
                                    <td><img src="{$val['logo']}" class="url_images"/></td>
                                    <td  class="text-left">{$val['name']}</td>
                                    <td>
                                        <nav data-href="{php echo $val['url']}" data-page_path="{$child['page_path']}" class="btn btn-default btn-sm" title="{$child['name']}"  data-type="{$val['url_type']}" >选择</nav>
                                    </td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                            <div class="pagerContent" pageNum="{$coupon_pageNum}" total="{$coupon_total}" id="couponPager" type="5" htmlID="couponList"></div>
                        </div>
                        <!--砍价商品-->
                        <div id="bargain" class="goods_list_content panel hide panel-default">
                            <table class="table table-hover table-responsive table-bordered">
                                <thead class="navbar-inner">
                                <tr>
                                    <th width="20%" class="text-center">商品图片</th>
                                    <th width="20%" class="text-center">商品名称</th>
                                    <th width="20%" class="text-center">操作</th>
                                </tr>
                                </thead>
                                <tbody id="bargainList">
                                {loop $bargain $key $val}
                                <tr class="text-center">
                                    <td><img src="{$val['logo']}" class="url_images"/></td>
                                    <td  class="text-left">{$val['name']}</td>
                                    <td>
                                        <nav data-href="{php echo $val['url']}" data-page_path="{$child['page_path']}" class="btn btn-default btn-sm" title="{$child['name']}"  data-type="{$val['url_type']}" >选择</nav>
                                    </td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                            <div class="pagerContent" pageNum="{$bargain_pageNum}" total="{$bargain_total}" id="bargainPager" type="6" htmlID="bargainList"></div>
                        </div>
                    </div>
                </div>
                <!--页面链接-->
                <div class="tab-pane " id="url_page">
                    {loop $pageInfo $item}
                        <div class="page-head"><h5 class="margin-0"><i class="fa fa-folder-open-o"></i> {$item['name']}</h5></div>
                        {loop $item['list'] $child}
                            <nav data-href="{php echo $child['url']}"  class="btn btn-default btn-sm" title="{$child['name']}" data-page_path="{$child['page_path']}" data-type="{$child['url_type']}" >{$child['name']}</nav>
                        {/loop}
                    {/loop}
                </div>
                <!--抢购专题-->
                <div class="tab-pane " id="url_rushspecial">
                    {loop $rushSpecial $item}
                        <nav data-href="{php echo $item['url']}"  class="btn btn-default btn-sm" title="{$item['title']}" data-page_path="{$item['page_path']}" data-type="{$item['url_type']}" >{$item['title']}</nav>
                    {/loop}
                </div>
                <!--自定义链接-->
                <div class="tab-pane " id="url_add_link">
                    <div class="page-search">
                        <div class="form-group">
                            <div class="col-sm-9">
                                <input id="diy_link_input" type="text" name="name" class="form-control col-sm-9"/>
                            </div>
                        </div>
                        <span id="diy_link" class="btn btn-primary min-width">添加</span>
                        <div class="form-group">
                            <div class="col-sm-9">
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="identical" value="1">同域名链接
                                </label>
                            </div>
                        </div>
                        <nav id="diy_link_nav" data-href="" class="btn btn-default hide btn-sm" title="自定义链接"></nav>
                    </div>
                </div>
                <!--小程序跳转-->
                <div class="tab-pane " id="url_add_appid">
                    <div class="page-search">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">小程序AppID</label>
                            <div class="col-sm-9">
                                <input id="add_appid_appid" type="text" class="form-control" value="" placeholder="请输入小程序AppID">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">小程序路径</label>
                            <div class="col-sm-9">
                                <input id="add_appid_path" type="text" class="form-control" value="" placeholder="请输入小程序路径">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <span id="add_appid_button" class="btn btn-primary min-width">添加</span>
                            </div>
                        </div>
                        <nav id="add_appid_nav" data-href="" class="btn btn-default hide btn-sm" title="添加appid"></nav>
                    </div>
                </div>
                <!--添加电话-->
                <div class="tab-pane " id="url_add_phone">
                    <div class="page-search">
                        <div class="col-sm-9">
                            <input id="add_phone_input" type="text" name="name" class="form-control col-sm-9"/>
                        </div>
                        <span id="add_phone_button" class="btn btn-primary min-width">添加</span>
                        <nav id="add_phone_nav" data-href="" class="btn btn-default hide btn-sm" title="添加电话"></nav>
                    </div>
                </div>
			</div>
        </div>
        <!--底部关闭-->
        <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
        </div>
        <script>
            //显示隐藏内容栏
            $("#selectUrlTab").on('click',"li",function () {
                //改变按钮样式
                $("#selectUrlTab li").removeClass("active");
                $(this).addClass("active");
                //显示隐藏内容
                var id = $(this).data("id");
                $("#selectUrlContent .tab-pane").removeClass("active");
                $("#url_"+id).addClass("active");
                //判断显示的内容是否为商品
                if(id == 'select_goods'){
                    //改变商品标题样式
                    $(".goods_option").removeClass('btn-primary');
                    $(".goods_option").removeClass('btn-default');
                    $(".goods_option").addClass('btn-default');
                    $(".goods_option:first").removeClass('btn-default');
                    $(".goods_option:first").addClass('btn-primary');
                    //显示第一种商品类型
                    $(".goods_list_content").addClass('hide');
                    $(".goods_list_content:first").removeClass('hide');
                }
            });
        	$(function(){
                //循环建立需要分页的内容的分页菜单
                $(".pagerContent").each(function () {
                    var id         = $(this).attr("id");
                    var total      = $(this).attr("total");//总条数
                    var pageNum    = $(this).attr("pageNum");//每页的数量
                    var total_page = Math.ceil(total/pageNum);//总共的页数
                    var page       = 1;//当前页数
                    //页数大于一 建立分页系统
                    if(total_page > 1) {
                        createPaging(id,total_page,page,pageNum);
                    }
                });
                //获取分页信息
                $(".pagerContent").on('click','span',function () {
                    var id = $(this).closest(".pagerContent").attr("id");//shopPager = 获取店铺信息
                    var htmlID = $(this).closest(".pagerContent").attr("htmlID");//渲染区域的id
                    var page = $(this).data("page");
                    var search = $(this).attr("search");
                    //1=抢购商品   2=团购商品  3=拼团商品  5=卡券信息
                    var  type = $(this).closest(".pagerContent").attr("type");
                    if(search == 'undefined'){
                        search = '';
                    }
                    var pageNum = $(this).attr("data-pageNum");
                    var url = biz.url("utility/select/getShop");
                    if(id != 'shopPager'){
                        url = biz.url("utility/select/getGoods");
                    }
                    $.ajax({
                        url:url,
                        data:{page:page,pageNum:pageNum,search:search,type:type},
                        dataType:"json",
                        success:function (res) {
                            var total_page = Math.ceil(res.data['total']/res.data['pageNum']);//总共的页数
                            if(total_page > 1){
                                createPaging(id,total_page,res.data['page'],res.data['pageNum'],search);
                            }else{
                                $("#"+id).html('');
                            }
                            if(id == 'shopPager'){
                                shopRendering(res.data,htmlID,id);
                            }else {
                                goodsRendering(res.data,htmlID,id);
                            }
                        }
                    });
                });
                //获取搜索信息
                $(".confirmSearch").on('click',function () {
                    var search = $(this).prev("div").children("input").val();
                    var position = $(this).closest(".tab-pane").contents(".app-table-list").contents(".panel").contents(".pagerContent");
                    var id = position.attr("id");//shopPager = 获取店铺信息
                    var htmlID = position.attr("htmlID");//渲染区域的id
                    //1=抢购商品   2=团购商品  3=拼团商品  5=卡券信息
                    var type = position.attr("type");
                    var page = 1;
                    var pageNum = position.attr("pageNum");
                    //获取请求地址
                    var url = biz.url("utility/select/getShop");
                    if(id != 'shopPager'){
                        //搜索商品的单独操作
                        url = biz.url("utility/select/getGoods");
                        var goodsType = $(".goods_option.btn-primary").data("type");
                        switch (goodsType) {
                            case 'rush': id = 'rushPager';break;//抢购
                            case 'fightgroup':id = 'fightgroupPager';break;//拼团
                            case 'groupon':id = 'grouponPager';break;//团购
                            case 'coupon':id = 'couponPager';break;//优惠券
                            case 'bargain':id = 'bargainPager';break;//砍价
                        }
                        type = $('#'+id).attr("type");
                        pageNum = $('#'+id).attr("pageNum");
                        htmlID = $('#'+id).attr("htmlID");
                    }
                    $.ajax({
                        url:url,
                        data:{page:page,pageNum:pageNum,search:search,type:type},
                        dataType:"json",
                        success:function (res) {
                            var total_page = Math.ceil(res.data['total']/res.data['pageNum']);//总共的页数
                            if(total_page > 1){
                                createPaging(id,total_page,res.data['page'],res.data['pageNum'],search);
                            }else{
                                $("#"+id).html('');
                            }
                            if(id == 'shopPager'){
                                shopRendering(res.data,htmlID,id);
                            }else {
                                goodsRendering(res.data,htmlID,id);
                            }
                        }
                    });
                });
                //点击选择商品类型
                $(".goods_option").on('click',function () {
                    //修改分类按钮样式
                    $(".goods_option").removeClass('btn-primary');
                    $(".goods_option").removeClass('btn-default');
                    $(".goods_option").addClass('btn-default');
                    $(this).removeClass('btn-default');
                    $(this).addClass('btn-primary');
                    //显示选中商品类型
                    let id = '#' + ($(this).data('type'));
                    $(".goods_list_content").addClass('hide');
                    $(id).removeClass('hide');
                });
                //点击添加自定义链接
                $("#diy_link").on('click',function () {
                    let link = $("#diy_link_input").val();
                    if(link.length <= 0){
                        tip.msgbox.err("不能为空!");
                        return false;
                    }
                    let indent = $("input[name=identical]:checked").val();
                    if(indent > 0){
                        link += '&indet=1';
                    }
                    $("#diy_link_nav").data("href",link);
                    $("#diy_link_nav").click();
                });
                //点击添加小程序跳转
                $("#add_appid_button").on('click',function () {
                    //参数获取
                    let app_id = $("#add_appid_appid").val(),
                        path   = $("#add_appid_path").val();
                    //判断内容是否为空
                    if(app_id.length <= 0 || path.length <= 0){
                        tip.msgbox.err("请完善内容后提交！");
                        return false;
                    }
                    //内容拼接  成为新的字符串   appid:wx58ed2758eab878fb,appurl:/pages/index/index
                    let new_content = 'appid:'+app_id+',appurl:'+path;
                    //添加内容
                    $("#add_appid_nav").data("href",new_content);
                    $("#add_appid_nav").click();
                });
                //点击添加添加电话
                $("#add_phone_button").on('click',function () {
                    let link = $("#add_phone_input").val();
                    if(link.length <= 0){
                        tip.msgbox.err("不能为空!");
                        return false;
                    }
                    $("#add_phone_nav").data("href",'tel:' + link);
                    $("#add_phone_nav").click();
                });
                //分页建立
                function createPaging(id,total,page,pageNum,search) {
                    var page_html = '';start = 0;end = 0;
                    if(page > 1){
                        page_html += "<span data-page='1'  data-pageNum='"+pageNum+"' search='"+search+"'>首页</span>";
                        page_html += "<span data-page='"+(parseInt(page) - parseInt(1))+"'  data-pageNum='"+pageNum+"' search='"+search+"'>上一页</span>";
                    }
                    if(page - 2 > 0){
                        start = parseInt(page) - 2;
                    }
                    if(start < 1){
                        start = 1;
                    }
                    end = parseInt(page) + 2;
                    if(end > total){
                        end = total;
                    }
                    for(var i= start ;i <= end;i++){
                        if(i == page){
                            page_html += "<span class='paging_Number active' data-page='"+i+"' data-pageNum='"+pageNum+"' search='"+search+"'>"+i+"</span>";
                        }else{
                            page_html += "<span class='paging_Number' data-page='"+i+"' data-pageNum='"+pageNum+"' search='"+search+"'>"+i+"</span>";
                        }
                    }
                    var show_num = 5;//显示的按钮数量
                    var but_num  = Math.floor(parseInt(show_num)/parseInt(2));//两边的数量
                    if(total > page){
                        page_html += "<span data-page='"+(parseInt(page) + parseInt(1))+"' data-pageNum='"+pageNum+"' search='"+search+"'>下一页</span>";
                        page_html += "<span data-page='"+total+"'  data-pageNum='"+pageNum+"' search='"+search+"'>尾页</span>";
                    }
                    $("#"+id).html(page_html);
                    // //删除多余的分页按钮
                    // if(total > show_num) {
                    //     if (page <= (parseInt(but_num) + parseInt(1))) {
                    //         //删除大于五的内容
                    //         $("#" + id + " .paging_Number:gt(" + (show_num - 1 ) + ")").remove();
                    //     } else if (page >= (parseInt(total) - parseInt(but_num))) {
                    //         //删除小于总页数减 show_num 的数的内容
                    //         var maxNumber = parseInt(total) - parseInt(show_num);
                    //         $("#" + id + " .paging_Number:lt(" + maxNumber + ")").remove();
                    //     } else {
                    //         //删除两边 当前数位移 but_num 数量后的内容
                    //         var min_num = parseInt(page) - (parseInt(but_num) + parseInt(1));//最小显示的页面 左
                    //         $("#" + id + " span:lt(" + min_num + ")").remove();
                    //         $("#" + id + " span:gt(" + (show_num - 1 ) + ")").remove();
                    //     }
                    // }
                }
                //店铺信息渲染
                function shopRendering(info,htmlID) {
                    var html = '';
                    var list = info['list'];
                    if(list && list != 'null') {
                        $.each(list, function (k, v) {
                            html += '<tr class="text-center">\n' +
                                '       <td><img src="' + v["logo"] + '" class="url_images"/></td>\n' +
                                '       <td  class="text-left">' + v["storename"] + '</td>\n' +
                                '       <td>' + v["storehours"] + '</td>\n' +
                                '       <td>\n' +
                                '           <nav data-href="' + v["url"] + '" class="btn btn-default btn-sm" title="' + v["storename"] + '" data-page_path="' + v["page_path"] + '"  data-type="'+v["url_type"]+'">选择</nav>\n' +
                                '       </td>\n' +
                                '   </tr>';
                        });
                        $("#" + htmlID).html(html);
                    }else{
                        $("#"+htmlID).html('');
                    }
                }
                //商品信息渲染
                function goodsRendering(info,htmlID) {
                    var html = '';
                    var list = info['list'];
                    if(list && list != 'null'){
                        $.each(list,function (k,v) {
                            html += '<tr class="text-center">\n' +
                                '       <td><img src="'+v["logo"]+'" class="url_images"/></td>\n' +
                                '       <td  class="text-left">'+v["name"]+'</td>\n' +
                                '       <td>\n' +
                                '           <nav data-href="'+v["url"]+'" class="btn btn-default btn-sm" title="'+v["name"]+'" data-page_path="'+v["page_path"]+'"  data-type="'+v["url_type"]+'" >选择</nav>\n' +
                                '       </td>\n' +
                                '   </tr>';
                        });
                        $("#"+htmlID).html(html);
                    }else{
                        $("#"+htmlID).html('');
                    }
                }

        		$(".select-btn").click(function(){
        			var type = $(this).data("type");
        			var kw = $.trim($("#select-"+type+"-kw").val());

        			if (type=='diyurl') {
                        if(!kw || kw==''){
                            tip.msgbox.err("请输入第三方链接");
                            return;
                        }
                        kw = kw.replace('http://', '');
                        kw = kw.replace('https://', '');
                        $('#select-diy-url').data('href', 'https://' + kw).trigger('click');
                        return;
                    }

                    if (type=='diymobile') {
                        if(!kw || kw==''){
                            tip.msgbox.err("请输入电话号码");
                            return;
                        }
                        $('#select-diy-diymobile').data('href','tel:'+kw).trigger('click');
                        return;
                    }

                    if (type=='diyxcx') {
                        if(!kw || kw==''){
                            tip.msgbox.err("请输入小程序APPID");
                            return;
                        }
                        if($("#select-diyxcxurl-kw").val() != ''){
                            $('#select-diy-diyxcx').data('href', 'appid:'+kw+',pagepath:'+$("#select-diyxcxurl-kw").val()).trigger('click');
                        }else{
                            $('#select-diy-diyxcx').data('href', 'appid:'+kw).trigger('click');
                        }
                        return;
                    }

        			$("#select-"+type+"-list").html('<div class="tip">正在进行搜索...</div>');
        			$.ajax("{php echo url('utility/select/urlquery', array('siteid' => intval($_GPC['siteid'])))}", {
		      			type: "get",
		      			dataType: "html",
		      			cache: false,
		      			data: {kw:kw, type:type}
		      		}).done(function (html) {
		      			$("#select-"+type+"-list").html(html);
		      		});
        		});
        	});
        </script>
    </div>

 
